-define(NODE, node).
-define(CLIENTSERVER, clientserver).
-define(STORAGE, store).
-define(NETWORK, dht).
-define(BACKEND, backend).

% Compile-time configuration
-include("config.hrl").

% Store state record

-record(store, {
        connected = false % bool
        }).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Chord record definitions
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-record(node,
 {
  position  = 0,   %% :: Int
  pid       = "",  %% :: String
  node      = ""   %% :: String
 }).

-record(chord,
 {
   identity     = #node{},
   finger_table = [],      %% :: [ #node ]
   predecessor  = #node{},

   setup        = nothing,
   lookup       = nothing,
   verbose      = true,
   status       = nothing
 }).

-record(chordparams,
 {
   n2  = nothing
 }).

% dht state records

-record(mesh, {
    nodes,           % :: ordsets % Connected nodes
    numberOfSuccs,   % :: int     % amount of redundancy
    successors = [], % :: [atom]
    predecessor,    % :: atom
    clocks,          % :: dict    % Vector clocks
    verbose          % :: bool
    }).


% Backend state records
-record(ets,{
        table,   % :: ETS  ; table id
        queue,   % :: queue; worker queue
        verbose  % :: bool
        }).

-record(ets_worker,{
        table,   % :: ETS table id
        verbose  % :: bool
        }).

-record(dict,{
        values,  % :: dict
        verbose  % :: bool
        }).
